<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Permutation Iterator</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Iterator">
<link rel="up" href="../specialized.html" title="Specialized Adaptors">
<link rel="prev" href="indirect.html" title="Indirect Iterator">
<link rel="next" href="reverse.html" title="Reverse Iterator">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="indirect.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../specialized.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reverse.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="iterator.specialized.permutation"></a><a class="link" href="permutation.html" title="Permutation Iterator">Permutation Iterator</a>
</h3></div></div></div>
<p>
        The permutation iterator adaptor provides a permuted view of a given range.
        That is, the view includes every element of the given range but in a potentially
        different order. The adaptor takes two arguments:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            an iterator to the range V on which the permutation will be applied
          </li>
<li class="listitem">
            the reindexing scheme that defines how the elements of V will be permuted.
          </li>
</ul></div>
<p>
        Note that the permutation iterator is not limited to strict permutations
        of the given range V. The distance between begin and end of the reindexing
        iterators is allowed to be smaller compared to the size of the range V, in
        which case the permutation iterator only provides a permutation of a subrange
        of V. The indexes neither need to be unique. In this same context, it must
        be noted that the past the end permutation iterator is completely defined
        by means of the past-the-end iterator to the indices.
      </p>
<h3>
<a name="iterator.specialized.permutation.h0"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.example"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.example">Example</a>
      </h3>
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">element_range_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">index_type</span><span class="special">;</span>

<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">element_range_size</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">index_size</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>

<span class="identifier">element_range_type</span> <span class="identifier">elements</span><span class="special">(</span> <span class="identifier">element_range_size</span> <span class="special">);</span>
<span class="keyword">for</span><span class="special">(</span><span class="identifier">element_range_type</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">el_it</span> <span class="special">=</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">;</span> <span class="identifier">el_it</span> <span class="special">!=</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">el_it</span><span class="special">)</span>
  <span class="special">*</span><span class="identifier">el_it</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">elements</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">el_it</span><span class="special">);</span>

<span class="identifier">index_type</span> <span class="identifier">indices</span><span class="special">(</span> <span class="identifier">index_size</span> <span class="special">);</span>
<span class="keyword">for</span><span class="special">(</span><span class="identifier">index_type</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">i_it</span> <span class="special">=</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">;</span> <span class="identifier">i_it</span> <span class="special">!=</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i_it</span> <span class="special">)</span>
  <span class="special">*</span><span class="identifier">i_it</span> <span class="special">=</span> <span class="identifier">element_range_size</span> <span class="special">-</span> <span class="identifier">index_size</span> <span class="special">+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">indices</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">i_it</span><span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">reverse</span><span class="special">(</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>

<span class="keyword">typedef</span> <span class="identifier">permutation_iterator</span><span class="special">&lt;</span> <span class="identifier">element_range_type</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">,</span> <span class="identifier">index_type</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">&gt;</span> <span class="identifier">permutation_type</span><span class="special">;</span>
<span class="identifier">permutation_type</span> <span class="identifier">begin</span> <span class="special">=</span> <span class="identifier">make_permutation_iterator</span><span class="special">(</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">);</span>
<span class="identifier">permutation_type</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">begin</span><span class="special">;</span>
<span class="identifier">permutation_type</span> <span class="identifier">end</span> <span class="special">=</span> <span class="identifier">make_permutation_iterator</span><span class="special">(</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">);</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"The original range is : "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">elements</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">" "</span> <span class="special">)</span> <span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"The reindexing scheme is : "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">indices</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">" "</span> <span class="special">)</span> <span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"The permutated range is : "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">begin</span><span class="special">,</span> <span class="identifier">end</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">" "</span> <span class="special">)</span> <span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Elements at even indices in the permutation : "</span><span class="special">;</span>
<span class="identifier">it</span> <span class="special">=</span> <span class="identifier">begin</span><span class="special">;</span>
<span class="keyword">for</span><span class="special">(</span><span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">index_size</span> <span class="special">/</span> <span class="number">2</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">it</span><span class="special">+=</span><span class="number">2</span> <span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">*</span><span class="identifier">it</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Permutation backwards : "</span><span class="special">;</span>
<span class="identifier">it</span> <span class="special">=</span> <span class="identifier">begin</span> <span class="special">+</span> <span class="special">(</span><span class="identifier">index_size</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">begin</span> <span class="special">);</span>
<span class="keyword">for</span><span class="special">(</span> <span class="special">;</span> <span class="identifier">it</span><span class="special">--</span> <span class="special">!=</span> <span class="identifier">begin</span> <span class="special">;</span> <span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">*</span><span class="identifier">it</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Iterate backward with stride 2 : "</span><span class="special">;</span>
<span class="identifier">it</span> <span class="special">=</span> <span class="identifier">begin</span> <span class="special">+</span> <span class="special">(</span><span class="identifier">index_size</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
<span class="keyword">for</span><span class="special">(</span><span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span> <span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">index_size</span> <span class="special">/</span> <span class="number">2</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">it</span><span class="special">-=</span><span class="number">2</span> <span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">*</span><span class="identifier">it</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
</pre>
<p>
        The output is:
      </p>
<pre class="programlisting">The original range is : 0 1 2 3 4 5 6 7 8 9
The reindexing scheme is : 9 8 7 6
The permutated range is : 9 8 7 6
Elements at even indices in the permutation : 9 7
Permutation backwards : 6 7 8 9
Iterate backward with stride 2 : 6 8
</pre>
<p>
        The source code for this example can be found <a href="../../../../example/permutation_iter_example.cpp" target="_top">here</a>.
      </p>
<h3>
<a name="iterator.specialized.permutation.h1"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.reference"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.reference">Reference</a>
      </h3>
<h4>
<a name="iterator.specialized.permutation.h2"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.synopsis"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.synopsis">Synopsis</a>
      </h4>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">ElementIterator</span>
  <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IndexIterator</span>
  <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ValueT</span>        <span class="special">=</span> <span class="identifier">use_default</span>
  <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CategoryT</span>     <span class="special">=</span> <span class="identifier">use_default</span>
  <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ReferenceT</span>    <span class="special">=</span> <span class="identifier">use_default</span>
  <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">DifferenceT</span>   <span class="special">=</span> <span class="identifier">use_default</span> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">permutation_iterator</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="identifier">permutation_iterator</span><span class="special">();</span>
  <span class="keyword">explicit</span> <span class="identifier">permutation_iterator</span><span class="special">(</span><span class="identifier">ElementIterator</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">IndexIterator</span> <span class="identifier">y</span><span class="special">);</span>

  <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">OEIter</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">OIIter</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">V</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">D</span> <span class="special">&gt;</span>
  <span class="identifier">permutation_iterator</span><span class="special">(</span>
    <span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">OEIter</span><span class="special">,</span> <span class="identifier">OIIter</span><span class="special">,</span> <span class="identifier">V</span><span class="special">,</span> <span class="identifier">C</span><span class="special">,</span> <span class="identifier">R</span><span class="special">,</span> <span class="identifier">D</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span>
    <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">enable_if_convertible</span><span class="special">&lt;</span><span class="identifier">OEIter</span><span class="special">,</span> <span class="identifier">ElementIterator</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span>
    <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">enable_if_convertible</span><span class="special">&lt;</span><span class="identifier">OIIter</span><span class="special">,</span> <span class="identifier">IndexIterator</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span>
  <span class="special">);</span>
  <span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">permutation_iterator</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">++();</span>
  <span class="identifier">ElementIterator</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">base</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="keyword">private</span><span class="special">:</span>
  <span class="identifier">ElementIterator</span> <span class="identifier">m_elt</span><span class="special">;</span>      <span class="comment">// exposition only</span>
  <span class="identifier">IndexIterator</span> <span class="identifier">m_order</span><span class="special">;</span>      <span class="comment">// exposition only</span>
<span class="special">};</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">ElementIterator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IndexIterator</span><span class="special">&gt;</span>
<span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">ElementIterator</span><span class="special">,</span> <span class="identifier">IndexIterator</span><span class="special">&gt;</span>
<span class="identifier">make_permutation_iterator</span><span class="special">(</span> <span class="identifier">ElementIterator</span> <span class="identifier">e</span><span class="special">,</span> <span class="identifier">IndexIterator</span> <span class="identifier">i</span><span class="special">);</span>
</pre>
<h4>
<a name="iterator.specialized.permutation.h3"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.requirements"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.requirements">Requirements</a>
      </h4>
<p>
        <code class="computeroutput"><span class="identifier">ElementIterator</span></code> shall model
        Random Access Traversal Iterator. <code class="computeroutput"><span class="identifier">IndexIterator</span></code>
        shall model Readable Iterator. The value type of the <code class="computeroutput"><span class="identifier">IndexIterator</span></code>
        must be convertible to the difference type of <code class="computeroutput"><span class="identifier">ElementIterator</span></code>.
      </p>
<h4>
<a name="iterator.specialized.permutation.h4"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.concepts"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.concepts">Concepts</a>
      </h4>
<p>
        <code class="computeroutput"><span class="identifier">permutation_iterator</span></code> models
        the same iterator traversal concepts as <code class="computeroutput"><span class="identifier">IndexIterator</span></code>
        and the same iterator access concepts as <code class="computeroutput"><span class="identifier">ElementIterator</span></code>.
      </p>
<p>
        If <code class="computeroutput"><span class="identifier">IndexIterator</span></code> models Single
        Pass Iterator and <code class="computeroutput"><span class="identifier">ElementIterator</span></code>
        models Readable Iterator then <code class="computeroutput"><span class="identifier">permutation_iterator</span></code>
        models Input Iterator.
      </p>
<p>
        If <code class="computeroutput"><span class="identifier">IndexIterator</span></code> models Forward
        Traversal Iterator and <code class="computeroutput"><span class="identifier">ElementIterator</span></code>
        models Readable Lvalue Iterator then <code class="computeroutput"><span class="identifier">permutation_iterator</span></code>
        models Forward Iterator.
      </p>
<p>
        If <code class="computeroutput"><span class="identifier">IndexIterator</span></code> models Bidirectional
        Traversal Iterator and <code class="computeroutput"><span class="identifier">ElementIterator</span></code>
        models Readable Lvalue Iterator then <code class="computeroutput"><span class="identifier">permutation_iterator</span></code>
        models Bidirectional Iterator.
      </p>
<p>
        If <code class="computeroutput"><span class="identifier">IndexIterator</span></code> models Random
        Access Traversal Iterator and <code class="computeroutput"><span class="identifier">ElementIterator</span></code>
        models Readable Lvalue Iterator then <code class="computeroutput"><span class="identifier">permutation_iterator</span></code>
        models Random Access Iterator.
      </p>
<p>
        <code class="computeroutput"><span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">E1</span><span class="special">,</span> <span class="identifier">X</span><span class="special">,</span> <span class="identifier">V1</span><span class="special">,</span>
        <span class="identifier">C2</span><span class="special">,</span> <span class="identifier">R1</span><span class="special">,</span> <span class="identifier">D1</span><span class="special">&gt;</span></code> is interoperable with <code class="computeroutput"><span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">E2</span><span class="special">,</span> <span class="identifier">Y</span><span class="special">,</span>
        <span class="identifier">V2</span><span class="special">,</span> <span class="identifier">C2</span><span class="special">,</span> <span class="identifier">R2</span><span class="special">,</span> <span class="identifier">D2</span><span class="special">&gt;</span></code>
        if and only if <code class="computeroutput"><span class="identifier">X</span></code> is interoperable
        with <code class="computeroutput"><span class="identifier">Y</span></code> and <code class="computeroutput"><span class="identifier">E1</span></code> is convertible to <code class="computeroutput"><span class="identifier">E2</span></code>.
      </p>
<h4>
<a name="iterator.specialized.permutation.h5"></a>
        <span class="phrase"><a name="iterator.specialized.permutation.operations"></a></span><a class="link" href="permutation.html#iterator.specialized.permutation.operations">Operations</a>
      </h4>
<p>
        In addition to those operations required by the concepts that <code class="computeroutput"><span class="identifier">permutation_iterator</span></code> models, <code class="computeroutput"><span class="identifier">permutation_iterator</span></code> provides the following
        operations.
      </p>
<pre class="programlisting"><span class="identifier">permutation_iterator</span><span class="special">();</span>
</pre>
<p>
        <span class="bold"><strong>Effects: </strong></span> Default constructs <code class="computeroutput"><span class="identifier">m_elt</span></code> and <code class="computeroutput"><span class="identifier">m_order</span></code>.
      </p>
<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">permutation_iterator</span><span class="special">(</span><span class="identifier">ElementIterator</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">IndexIterator</span> <span class="identifier">y</span><span class="special">);</span>
</pre>
<p>
        <span class="bold"><strong>Effects: </strong></span> Constructs <code class="computeroutput"><span class="identifier">m_elt</span></code>
        from <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">m_order</span></code> from <code class="computeroutput"><span class="identifier">y</span></code>.
      </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">class</span> <span class="identifier">OEIter</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">OIIter</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">V</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">D</span> <span class="special">&gt;</span>
<span class="identifier">permutation_iterator</span><span class="special">(</span>
  <span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">OEIter</span><span class="special">,</span> <span class="identifier">OIIter</span><span class="special">,</span> <span class="identifier">V</span><span class="special">,</span> <span class="identifier">C</span><span class="special">,</span> <span class="identifier">R</span><span class="special">,</span> <span class="identifier">D</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">r</span>
  <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">enable_if_convertible</span><span class="special">&lt;</span><span class="identifier">OEIter</span><span class="special">,</span> <span class="identifier">ElementIterator</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span>
  <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">enable_if_convertible</span><span class="special">&lt;</span><span class="identifier">OIIter</span><span class="special">,</span> <span class="identifier">IndexIterator</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">*</span> <span class="special">=</span> <span class="number">0</span>
<span class="special">);</span>
</pre>
<p>
        <span class="bold"><strong>Effects: </strong></span> Constructs <code class="computeroutput"><span class="identifier">m_elt</span></code>
        from <code class="computeroutput"><span class="identifier">r</span><span class="special">.</span><span class="identifier">m_elt</span></code> and <code class="computeroutput"><span class="identifier">m_order</span></code>
        from <code class="computeroutput"><span class="identifier">y</span><span class="special">.</span><span class="identifier">m_order</span></code>.
      </p>
<pre class="programlisting"><span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
        <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="special">*(</span><span class="identifier">m_elt</span> <span class="special">+</span> <span class="special">*</span><span class="identifier">m_order</span><span class="special">)</span></code>
      </p>
<pre class="programlisting"><span class="identifier">permutation_iterator</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">++();</span>
</pre>
<p>
        <span class="bold"><strong>Effects: </strong></span> <code class="computeroutput"><span class="special">++</span><span class="identifier">m_order</span></code><br> <span class="bold"><strong>Returns:
        </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
      </p>
<pre class="programlisting"><span class="identifier">ElementIterator</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">base</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
        <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">m_order</span></code>
      </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">ElementIterator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">IndexIterator</span><span class="special">&gt;</span>
<span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">ElementIterator</span><span class="special">,</span> <span class="identifier">IndexIterator</span><span class="special">&gt;</span>
<span class="identifier">make_permutation_iterator</span><span class="special">(</span><span class="identifier">ElementIterator</span> <span class="identifier">e</span><span class="special">,</span> <span class="identifier">IndexIterator</span> <span class="identifier">i</span><span class="special">);</span>
</pre>
<p>
        <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">permutation_iterator</span><span class="special">&lt;</span><span class="identifier">ElementIterator</span><span class="special">,</span> <span class="identifier">IndexIterator</span><span class="special">&gt;(</span><span class="identifier">e</span><span class="special">,</span> <span class="identifier">i</span><span class="special">)</span></code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003, 2005 David Abrahams Jeremy Siek Thomas
      Witt<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at &lt;ulink url="http://www.boost.org/LICENSE_1_0.txt"&gt;
        http://www.boost.org/LICENSE_1_0.txt &lt;/ulink&gt;)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="indirect.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../specialized.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reverse.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
